package com.example.second_home_work

import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat


class MainActivity2 : AppCompatActivity() {
    private var count = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main2)

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        val button = findViewById<Button>(R.id.button)
        val linearLayout = findViewById<LinearLayout>(R.id.linearLayout)
        val button4 = findViewById<Button>(R.id.button4)
        val textView = findViewById<TextView>(R.id.textView)
        val spinner = findViewById<android.widget.Spinner>(R.id.spinner)
        val ProgramExpert = ProgramExpert()

        button.setOnClickListener {
            Log.d("MainActivity2", "Button clicked!")
            val textView = TextView(this)
            count++
            textView.text = "New TextView $count!"
            textView.textSize = 30f
            linearLayout.addView(textView)
        }

        button4.setOnClickListener {
            textView.text = ProgramExpert.getLanguage(spinner.selectedItem.toString())
        }

    }
}
